import java.util.Iterator;
import java.util.Scanner;

public class Demo {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for (int i = 0;;) {
			System.out.println("请输入高度");
			double height = sc.nextDouble();
			System.out.println("请输入反弹的次数");
			int count = sc.nextInt();
			h(height, count);
		}

	}

	/**
	 * 一球从h米高度自由落下，每次落地后反跳回原高度的一半；再落下， 求它在 第n次落地时，共经过多少米？第n次反弹多高？
	 * 
	 * @param height
	 * @param count
	 */
	static void h(double height, int count) {
		double length = 0;
		for (int i = 1; i <= count; i++) {
			if (i == 1) {
				length = height;
				System.out.println();
			} else {
				length += height * 2;
			}
			
			height /= 2;// 第n次反弹的高度
		}
		
		System.out.printf("第%s次落地时，共经过%s多少米", count, length);
		System.out.println();
		System.out.printf("第%s次反弹%s米", count, height);
	}

}
